#!/usr/bin/env python
# encoding: utf-8
# Date: 2017-06-19 09:04:25
# file:models.py
# Email: wang521kang@outlook.com
# Author: 王康
from django.db import models


class Commodity(models.Model):
    name = models.CharField(max_length=255, verbose_name=u'商品名称')
    price = models.IntegerField(default=0, verbose_name=u'商品单价')
    preferential = models.CharField(max_length=255, null=True, verbose_name=u'商品优惠')
    commodity_classification = models.ForeignKey('CommodityClassification', verbose_name=u'商品分类主键')


class CommodityImg(models.Model):
    commodity = models.ForeignKey(Commodity, verbose_name=u'商品主键')
    img_url = models.CharField(max_length=255, blank=True, null=True, verbose_name=u'图片地址')
    is_active = models.BooleanField(default=True, verbose_name=u'是否删除')


class CommodityProperty(models.Model):
    commodity = models.ForeignKey(Commodity, verbose_name=u'商品主键')
    property = models.CharField(max_length=255, verbose_name=u'商品属性')


class CommodityPropertyValue(models.Model):
    commodity_property = models.ForeignKey(CommodityProperty, verbose_name=u'商品属性主键')
    value = models.CharField(max_length=255, verbose_name=u'商品属性的值')


class CommodityClassification(models.Model):
    commodity_classification = models.ForeignKey('CommodityClassification', null=True, verbose_name=u'商品分类主键')
    classification = models.CharField(max_length=255, verbose_name=u'商品分类')
    px = models.IntegerField(default=0, verbose_name=u'分类排序')
